$('#slider1').slider();
var vm = new Vue({
	el: '#app',
	data: {
		items: [],
		loaded: false
	},
	mounted: function() {
		index();
		getB();
		getTransferAccounts();
	}
});

function index() {
	$.ajax({
		type: "GET",
		url: ip + "trade/finance/serverGetUserAccountList.o",
		xhrFields: {
			withCredentials: true
		},
		crossDomain: true,
		success: function(data) {
			if(data.statusCode == 0) {
				vm.loaded = true;
				$("#img").append("<img src='" + data.result[0].tradeCoin.img + "'>");
				$("#title").text(data.result[0].tradeCoin.title);
				$("#ky").text(data.result[0].balanceAmount);
				$("#ysf").text(data.result[0].unFreezeAmount);
			} else if(data.statusCode == 1000) {
				$.toptip("登录失效！", 'error');
				setTimeout('window.location.href = "signIn.html"', 1000);
			} else {
				$.toptip(data.resultDesc, 'error');
			}
		}
	});
}
window.onbeforeunload = function(e) {
	localStorage.removeItem('txl2');
}

function getTransferAccounts() {
	var txl2 = localStorage.getItem("txl2");
	$("#money").val(txl2);
}
/**
 * 扫描二维码并且解析
 */
function startCan() {
	setTimeout('window.location.href = "qr2.html"', 100);
}

var first = true;

function serverTransOut() {
	//	    $(".weui-btn").attr("disabled", false);
	var options = $("#line option:selected").val();
	var serverTransOutReqbody = {
		"type": options,
		"addr": $("#money").val().trim(),
		"payPwd": $("#payPwd").val().trim(),
		"num": $("#num").val().trim()
	};
	if(first) {
		first = false;
		$.ajax({
			type: "POST",
			url: ip + "platform/wallet/serverTransOut.m",
			xhrFields: {
				withCredentials: true
			},
			crossDomain: true,
			data: serverTransOutReqbody,
			success: function(data) {
				if(data.statusCode == 0) {
					//					$(".weui-btn").attr("disabled", true);
					$.toptip("提取成功！", 'success');
					setTimeout('window.location.href = "HMSAdministration.html"', 1000);
				} else if(data.statusCode == 1000) {
					$.toptip("登录失效！", 'error');
					setTimeout('window.location.href = "signIn.html"', 1000);
				} else {
					$.toptip(data.resultDesc, 'error');
					first = true;
				}
			}
		});
	}
}
/**
 * 获取币的信息
 */
function getB() {
	$.ajax({
		type: "POST",
		url: ip + "trade/finance/getCoinMinLimit.o",
		xhrFields: {
			withCredentials: true
		},
		crossDomain: true,
		success: function(data) {
			if(data.statusCode == 0) {
				$("#minLimit").text(data.result.minLimit);
			} else if(data.statusCode == 1000) {
				$.toptip("登录失效！", 'error');
				setTimeout('window.location.href = "signIn.html"', 1000);
			} else {
				$.toptip(data.resultDesc, 'error');
			}
		}
	});
}
/**
 * 打开通讯录2
 */
function dakTxl() {
	setTimeout('window.location.href = "mailList2.html"', 100);
	var v = $("#line").val();
	localStorage.setItem('v', v);
}
var v = localStorage.getItem("v");
if(v == null || v == 2) {
	$("#line").val(2)
} else if(v == 1) {
	$("#line").val(1)
} else {

}! function($, ydui) {
	var dialog = ydui.dialog;
	var $keyboard = $('#J_KeyBoard');
	// 初始化参数
	$keyboard.keyBoard({
		disorder: true, // 是否打乱数字顺序
		title: 'HMS安全键盘' // 显示标题
	});
	// 打开键盘
	$('.J_OpenKeyBoard').on('click', function() {
		$keyboard.keyBoard('open');
	});
	// 六位密码输入完毕后执行
	$keyboard.on('done.ydui.keyboard', function(ret) {
		$(".J_OpenKeyBoard").val(ret.password);
		// 关闭键盘
		$keyboard.keyBoard('close');
	});
}(jQuery, YDUI);